// 函数组件没有生命周期
import { Component, ReactNode } from "react";
type Istate={
    msg:string
}
type Iprops={
    name:string
}
class Child extends Component<Iprops,Istate>{
    state={
        msg:'无望'
    }
    // componentWillMount(): void {
    //     console.group('child的componentWillMount')
    //     console.log('prevProps',this.props);
    //     console.groupEnd()
    // }
    componentDidMount(): void {
        console.group('child的componentDidMount')
        console.log('prevProps',this.props);
        console.groupEnd()
    }
    // componentWillReceiveProps(nextProps: Readonly<Iprops>, nextContext: any): void {
    //     // 组件即将接收到新的proprs时触发
    //     console.group('child的componentWillReceiveProps')
    //     console.log('nextProps',nextProps);
    //     console.log('prevProps',this.props);
    //     console.groupEnd()
        
    // }
    // componentWillUpdate(nextProps: Readonly<Iprops>, nextState: Readonly<Istate>, nextContext: any): void {
    //     console.group('child的componentWillUpdate')
    //     console.log('nextProps',nextProps);
    //     console.log('prevProps',this.props);
    //     console.groupEnd()
    // }
    componentDidUpdate(prevProps: Readonly<Iprops>, prevState: Readonly<Istate>, snapshot?: any): void {
        console.group('child的componentWillUpdate')
        console.log('prevProps',prevProps);
        console.log('prevProps',this.props);
        console.groupEnd()
    }
    render(): ReactNode {
        console.group('child的render');
        console.log('child的render');
        console.groupEnd()
        
        
        return(
            <fieldset>
                <legend>子组件</legend>
                <h1>接收的props{this.props.name}</h1>
            </fieldset>
        )
    }
}

export default Child